import Taro from "@tarojs/taro";
import { showModal, Storage, showToast } from "./tools/public.js";
import requestSubscribeMessage from "./subscribeMessage.js";
/**
 * 身份未认证跳转到认证页面
 * __isVerified ===1
 * path: 目标路径
 * type:
 * say:发布微事
 * activity:活动
 * volunteer:申请志愿者
 * qa:问答
 */

 function navigateToVerfied(auth, path, type) {
  if (auth === 1 || Storage.getSync("isVerified")) {
    Taro.navigateTo({
      url: path,
    });
  } else {
    showModal("提示", "您还未进行身份认证，请认证后操作", {
      confirmColor: "#E32416",
      confirmText: "去认证",
      success: (res) => {
        if (res.confirm) {
          requestSubscribeMessage([1, 5, 9])
            .then((r) => {
              console.log("订阅消息", r);
              Taro.navigateTo({
                url: `/subs/interactive/pages/verified/verified?from=${type}`,
              });
            })
            .catch((error) => {
              console.log(error.message);
              showToast("请订阅后再操作");
            });
        }
      },
    });
  }
}
export  {navigateToVerfied} 